package org.zjx.battle;

import org.zjx.battle.engines.NormalBattleEngine;
import org.zjx.battle.entity.Battle;

import java.util.ArrayList;
import java.util.List;

public class BattleEngineFactory {
    private static final List<IBattleEngine> engines = new ArrayList<>();

    static {
        // 注册所有引擎
        engines.add(new NormalBattleEngine());
    }

    /**
     * 根据战斗类型选择合适的引擎
     * @param battle 战场对象
     * @return 合适的战斗引擎
     */
    public static IBattleEngine getEngineForWar(Battle battle) {
        return engines.stream()
                .filter(engine -> engine.isApplicable(battle))
                .findFirst()
                .orElseThrow(() -> new IllegalStateException("没有找到合适的战斗引擎"));
    }
}
